<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    手机号码:<input type="number"><button>验证码</button>;
    <script>
        /* 需求  1.点击按钮，开启倒计时，按钮禁用，
                2. 倒计时结束，按钮恢复 */
    var btn=document.querySelector('button');
    btn.addEventListener('click',function(){
        var nb=3;
        this.disabled=true;  // disabled 按钮的属性  禁用
        btn.innerHTML=nb;

        var time1=setInterval(() => {
            nb--;
            btn.innerHTML=nb;
            if(nb==0){
                clearInterval(time1);
                this.disabled=false;
                this.innerHTML='验证码';
            }
        }, 1000);
    });
    </script>
</body>
</html>